//SPDX-FileCopyrightText: Copyright 2022-2024 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

package impl

import "strings"

func Dir(path string) string {
	path = strings.TrimRight(path, "/")
	pos := strings.LastIndex(path, "/")
	if pos == 0 {
		return "/"
	}
	return strings.TrimRight(path[:pos], "/")
}
